#pragma once

#include "IEndPoint.h"
#include "IContractChecker.h"

namespace RoomFW {

struct IActiveObject;

//
// Class:	LocalEndPoint
//
// Description:	Implementation of a Local EndPoint.  Used binding local ports.
//
// Author:	Andrew Sage
//
class LocalEndPoint : public IEndPoint
{
public:

	//
	// Method:	LocalEndPoint
	//
	// Description:	Constructor
	//
	// Parameters:
	//
	//	activeObject - Object that accepted messages will be put to.
	//
	//	portIndex - Port index accepted messages marked for.
	//
	LocalEndPoint(IActiveObject* activeObject, const PortIndex& portIndex);

	//
	// IEndpoint overrides.
	//
	virtual SendMessageError::Reason acceptMessage(
		MessageID messageID,
		IPayloadSP& payload,
		const char* senderName,
		IEndPointSP replyEndpoint = IEndPointSP());

	//
	// Accessors.
	//
	void setReplication(size_t replication) { portIndex_.replication(replication); }
	PortIndex getPortIndex() { return portIndex_; }

private:

	//
	// Active object that recieves accepted messages.
	//
	IActiveObject* activeObject_;

	//
	// Port index accepted messages marked for.
	//
	PortIndex portIndex_;

	//
	// Contract checker to check incoming message.
	//
	IContractCheckerSPC contractChecker_;
};
typedef ::boost::shared_ptr<LocalEndPoint> LocalEndPointSP;

}
